package com.nbsaas.boot.store.rest.convert;

import com.nbsaas.boot.store.data.entity.Store;
import com.nbsaas.boot.store.api.domain.request.StoreRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.shop.data.entity.Shop;
            import com.nbsaas.boot.store.data.entity.StoreCatalog;
            import com.nbsaas.boot.trade.data.entity.TradeAccount;

/**
* 请求对象转换成实体对象
*/

public class StoreEntityConvert  implements Converter<Store, StoreRequest> {

    @Override
    public Store convert(StoreRequest source) {
        Store result = new Store();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getShop()!=null){
                    Shop shop =new Shop();
                    shop.setId(source.getShop());
                    result.setShop(shop);
                    }
                    if(source.getStoreCatalog()!=null){
                    StoreCatalog storeCatalog =new StoreCatalog();
                    storeCatalog.setId(source.getStoreCatalog());
                    result.setStoreCatalog(storeCatalog);
                    }
                    if(source.getAccount()!=null){
                    TradeAccount account =new TradeAccount();
                    account.setId(source.getAccount());
                    result.setAccount(account);
                    }
        return result;
    }
}

